test: RecordService 단위 테스트 추가 + updateRecord IDOR 수정 - #214
Merged
Conversation
createRecord/getRecordByUser/updateRecord/deleteRecords 전체 메서드에 대해 정상 케이스 + 예외 케이스 + 경계값 검증 (18개). 테스트 작성 중 CourseService.updateCourse와 동일한 패턴의 버그 발견해 수정: - updateRecord: userId 파라미터를 받지만 소유권 검증을 하지 않아 다른 사람의 기록 제목도 수정 가능했음 (IDOR). deleteRecords는 이미 소유권을 검증하고 있어서(PermissionDeniedException), 동일 패턴으로 맞춰서 수정. ErrorStatus.PERMISSION_DENIED_RECORD_UPDATE_EXCEPTION 추가. getRecordByUser의 건강 데이터 조회 실패 시 전체 요청은 실패하지 않고 healthData만 null로 우아하게 처리되는 방어 로직도 별도로 검증함.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesRecord authorization and service coverage
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
테스트 커버리지 확장 3단계.
RecordService(러닝 기록 생성/조회/수정/삭제) 전체 메서드에 대해 단위 테스트 작성. 테스트 작성 중 CourseService.updateCourse와 동일한 패턴의 IDOR 버그를 발견해 함께 수정.테스트 (18개, @nested로 메서드별 구성)
createRecord: courseId/publicCourseId 각각으로 생성, 코스/공개코스/유저 없음, 시간 형식 오류getRecordByUser: 정상 매핑, publicCourseId 매핑, 건강 데이터 포함/미포함, 건강 데이터 조회 실패해도 전체 요청은 안 깨지는 방어 로직 검증, 빈 목록updateRecord: 정상 수정, 기록 없음, 소유자 아니면 거부deleteRecords: 정상 삭제, 존재하지 않는 id 포함, 소유자 아닌 기록 포함, 유저 없음발견해서 수정한 버그
updateRecordIDOR:userId파라미터를 받으면서 소유권 검증을 안 해 다른 사람 기록의 제목도 수정 가능했음. 같은 서비스의deleteRecords는 이미PermissionDeniedException으로 소유권을 검증하고 있어서, 동일 패턴(record.getRunnectUser().getId().equals(userId))으로 맞춰 수정.ErrorStatus.PERMISSION_DENIED_RECORD_UPDATE_EXCEPTION신규 추가.검증
./gradlew build전체(기존 ServerApplicationTests 포함) 통과 확인Summary by CodeRabbit